package com.wp.service.impl;

import com.wp.mapper.AdminMapper;
import com.wp.pojo.Admin;
import com.wp.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;

@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminMapper adminMapper;
    /**
     * 管理员登录
     * */
    @Override
    public String login(Admin admin) {
        //MD5加密
        String password=admin.getPassword();
        String md5password = DigestUtils.md5DigestAsHex(password.getBytes());
        //加密完成，token替换原密码并返回前端
        admin.setPassword(md5password);
        Admin admin1=adminMapper.login(admin);
        String token=admin1.getPassword();
        return token;
    }
}
